package com.spdb.oa.type;

import java.util.List;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlRootElement;


public class WorkflowOpinion {
	
	@Override
	public String toString() {
		return "WorkflowOpinion [processId=" + processId + ", instanceId=" + instanceId + ", distributionId="
				+ distributionId + ", title=" + title + ", departmentOpinions=" + departmentOpinions + "]";
	}

	public static class DepartmentOpinion {
		
		@XmlAttribute(name="ID")
		public String id;
		@XmlAttribute(name="Name")
		public String name;
		@XmlAttribute(name="DisplayName")
		public String displayName;
		@XmlAttribute(name="ControlType")
		public String controlType;
		@XmlAttribute(name="DataType")
		public String dataType;		
		
		@XmlElementWrapper(name="Items")
		@XmlElements(value={@XmlElement(name="ItemHeader", type=WorkflowOpinion.Header.class),
				@XmlElement(name="Item", type=WorkflowOpinion.Opinion.class)})
		public List<WorkflowOpinion.Opinion> opinions;
		
		@Override
		public String toString() {
			return "DepartmentOpinion [opinions=" + opinions + ", header=" + header + "]";
		}

		@XmlElement
		public WorkflowOpinion.Header header;
	}
	
	public static class Opinion {
		@XmlElement(name="StepName")
		public String stepName;
		@XmlElement(name="Dealer")
		public String dealer;
		@XmlElement(name="DealDateTime")
		public String dealDateTime;
		@XmlElement(name="SendTo")
		public String sendTo;
		@XmlElement(name="DealOpinion")
		public String dealOpinion;
		@XmlElement(name="SignOpinion")
		public String signOpinion;
		@Override
		public String toString() {
			return "Opinion [stepName=" + stepName + ", dealer=" + dealer + ", dealDateTime=" + dealDateTime
					+ ", sendTo=" + sendTo + ", dealOpinion=" + dealOpinion + "]";
		}
	}
	
	public static class Header extends Opinion {
		
	}
	
	
	@XmlElement(name="ProcessID")
	public String processId;
	@XmlElement(name="InstanceID")
	public String instanceId;
	@XmlElement(name="DistributionID")
	public String distributionId;
	@XmlElement(name="Title")
	public String title;
	
	@XmlElementWrapper(name="WorkFlowOpinionItems")
	@XmlElements(value = { @XmlElement(name="WorkFlowOpinionItem", type=WorkflowOpinion.DepartmentOpinion.class) })
	public List<WorkflowOpinion.DepartmentOpinion> departmentOpinions;
}
